
             
/**
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * @File name:  UpdateTPersonnalAction.java   【员工信息:T_PERSONNAL】
 * @Create on:  2012-06-25 21:11:292
 * @Author   :  陈伟
 * @Copyright 
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */

           
        

package com.boho.ecp.deposit.staff.action;

            
import java.sql.Connection;
import java.util.Date;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.POUtils;
import cn.boho.framework.service.MessageService;

import com.boho.ecp.constant.Staff;
import com.boho.ecp.po.TPersonnalPO;
import com.boho.ecp.util.MatchUtils;
            
        
public class UpdateTPersonnalAction extends ActionImp {
	private TPersonnalPO conditionTPersonnalPO = new TPersonnalPO();
	private TPersonnalPO valueTPersonnalPO = new TPersonnalPO();
	private Date date = new Date();
	private Connection con=null;
	private Integer personnalID;
	private String personnalNo;
	private String personnalName;
	private String post;
	private Integer storeNo;
	private String updateBy;
	
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			atx.setErrorContext("BOHO_COMMON_1002", MessageService.getMessage("BOHO_COMMON_1002"),"更新员工信息" ,ex);
		}
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		if(MatchUtils.isEmpty(personnalID)){
			valueTPersonnalPO.setPersonnalNo(personnalNo);
			valueTPersonnalPO.setPersonnalName(personnalName);
			valueTPersonnalPO.setPost(post);
			valueTPersonnalPO.setStoresNo(storeNo);
			valueTPersonnalPO.setCreateBy(updateBy);
			valueTPersonnalPO.setCreateDate(date);
			POUtils.insert(con, valueTPersonnalPO, false);
		}
		else{
			conditionTPersonnalPO.setPersonnalId(personnalID);
			valueTPersonnalPO.setPersonnalNo(personnalNo);
			valueTPersonnalPO.setPersonnalName(personnalName);
			valueTPersonnalPO.setPost(post);
			valueTPersonnalPO.setStoresNo(storeNo);
			valueTPersonnalPO.setUpdateBy(updateBy);
			valueTPersonnalPO.setUpdateDate(date);
			POUtils.update(con, conditionTPersonnalPO, valueTPersonnalPO,false);
		}
		
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		updateBy = atx.getStringValue(Staff.STAFF_SESSION_NO);
		personnalID = atx.getIntegerValue("PERSONNAL_ID",-1);
		personnalNo = atx.getStringValue("PERSONNAL_NO");
		personnalName = atx.getStringValue("PERSONNAL_NAME");
		post = atx.getStringValue("POST");
		storeNo = atx.getIntegerValue("STORES_NO");
		return 1;
	}
}
